#include <bits/stdc++.h>
#ifndef DEBUG
#define debug
#endif
using namespace std;
using i64 = int64_t;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> pre(n + 2, -1), nxt(n + 2, -1);
  vector<i64> val(n + 2);
  for (int i = 1; i <= n; i ++) cin >> val[i];
  for (int i = 0; i <= n; i ++) nxt[i] = i + 1;
  for (int i = 1; i <= n + 1; i ++) pre[i] = i - 1;
  using pii = pair<i64, int>;
  priority_queue<pii, vector<pii>, greater<pii>> pq;
  for (int i = 1; i <= n; i ++) pq.emplace(val[i], i);
  while (k) {
    auto [v, node_id] = pq.top();
    pq.pop();
    if (v != val[node_id] || node_id == 0 || node_id == n + 1) continue;
    k --;
    val[node_id] = -1;
    int prev = pre[node_id], next = nxt[node_id];
    nxt[prev] = next;
    pre[next] = prev;
    val[prev] += v;
    val[next] += v;
    pq.emplace(val[prev], prev);
    pq.emplace(val[next], next);
  }
  for (int cur = nxt[0]; cur != n + 1; cur = nxt[cur]) {
    cout << val[cur] << ' ';
  }
  cout << endl;
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int T = 1;
  // cin >> T;
  for (int cas = 1; cas <= T; cas ++) {
    solve();
  }
}